/**
 * 
 */
package com.jdy.haoduoaiteacher.activity;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.ycsj.goldmedalnewconcept.R;

import org.droidparts.annotation.inject.InjectView;

//import com.jdy.haoduoaiteacher.R;

/**
 * @author zp 2016-4-19 上午9:47:15
 */
public class TestSpecificationActivity extends BaseActivity {

  @InjectView(id = R.id.webView)
  private WebView webView;

  private int positionY = 0;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test_specification_layout);

    String title = getIntent().getStringExtra("title");
    setTitle(title);

    WebSettings settings = webView.getSettings();

    settings.setBuiltInZoomControls(true);// 是否显示缩放按钮，默认false

    settings.setUseWideViewPort(true);// 设置此属性，可任意比例缩放。大视图模式

    settings.setLoadWithOverviewMode(true);// 和setUseWideViewPort(true)一起解决网页自适应问题

    if (title.contains("测试说明")) {
      String data = "<body>" + "<img src=\"test_specification.png\"/></body>";

      webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html",
          "utf-8", null);
    } else if (title.contains("AR互动说明")) {
      String data = "<body>" + "<img src=\"ar_specification.png\"/></body>";

      webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html",
          "utf-8", null);
    }

    else if (title.contains("使用说明")) {
      String data = "<body>" + "<img src=\"op_explain.png\"/></body>";

      webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html",
          "utf-8", null);
    }

  }

  @Override
  public void onResume() {
    super.onResume();
    webView.post(new Runnable() {
      @Override
      public void run() {
        webView.scrollTo(0, positionY);
      }
    });
  }

  @Override
  public void onPause() {
    super.onPause();
    positionY = webView.getScrollY();
  }
}
